


function reSubmitForm()
{
	alert('resubmit');
	var submitTimeoutId;
	$('#searchForm').ajaxSubmit({
		target: "#resultDiv",
		beforeSubmit: function (){
			submitTimeoutId = window.setTimeout(reSubmitForm, 10000, true);
		},
		success: function() {
			$("#content").html('');
			$("#resultDiv").hide();
			$("#resultDiv").fadeIn(2000);
			$('input[id="loading_search"]').val(0);
			window.clearTimeout(submitTimeoutId);
		}
	});
}

/**
 * Fonction javascript load_js
 * 
 * @param lang
 */
function load_js(lang) {
//	Chargement du formulaire
	var img_loading = 'loading.gif';
	$(document).ready(function() {

		// Définit l'image de chargement en fonction de la langue 
		var img_loading = 'loading.gif';
		if(lang != 'fr') img_loading = 'loading_2.gif';

		// bind form using ajaxForm
		var submitTimeoutId;
		if($('#searchForm').length > 0) {
			$('#searchForm').ajaxForm({
				target: "#resultDiv",
				beforeSubmit: function (){
					if($('input[id="loading_search"]').val() == 0)
						{$('input[id="loading_search"]').val(1);
						submitTimeoutId = window.setTimeout(reSubmitForm, 10000, true);
						}
					else	{return false;}
				},
				success: function() {
					$("#content").html('');
					$("#resultDiv").hide();
					$("#resultDiv").fadeIn(2000);
					$('input[id="loading_search"]').val(0);
					window.clearTimeout(submitTimeoutId);
				}
			});
		} else {
			$("#mainForm").ajaxForm({
				target: "#main",
				beforeSubmit: function (){
					if($('input[id="loading_search"]').val() == 0)
						{$('input[id="loading_search"]').val(1);}
					else	{return false;}
				},
				success: function() {
					$("#content").html('');
					$("#resultDiv").hide();
					$("#resultDiv").fadeIn(2000);
					$('input[id="loading_search"]').val(0);
				}
			});
		}
		//	bouton 'loading'
		$(".lsb").click(function() {
			$("#resultDiv").html('<img src="UI/Template/Style/'+ img_loading +'">');
			$("#loadMain").html('<img src="UI/Template/Style/'+ img_loading +'">');
			$("#content").html('<img src="UI/Template/Style/loading_mini.gif">');
		});
	});

}